package com.easy.easy.Service.impl;

import com.easy.easy.Service.IAddressService;
import com.easy.easy.bean.Useraddress;
import com.easy.easy.dao.UserAddressDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class UserAddressServiceimpl implements IAddressService {
    @Autowired
    UserAddressDao userAddressDao;
    @Override
    public int add(Useraddress address) {
        return userAddressDao.add(address);
    }

    @Override
    public int edit(Useraddress address) {
        return userAddressDao.edit(address);
    }

    @Override
    public int delete(int id) {
        return userAddressDao.delete(id);
    }

    @Override
    public Useraddress getAddressByID(int id) {
        return userAddressDao.getAddressByID(id);
    }

    @Override
    public List<Useraddress> getAddressByUserID(int userid) {
        return userAddressDao.getAddressByUserID(userid);
    }

    @Override
    public int cancelDefault(int id) {
        return userAddressDao.cancelDefault(id);
    }

    @Override
    public int setDefault(int userid,int id) {
        userAddressDao.cancelDefault(id);
        return userAddressDao.setDefault(userid,id);
    }
}
